/*package comp4081.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import comp4081.hibernate.Customer;
import comp4081.hibernate.Employee;
import comp4081.hibernate.HibernateUtil;


*//**
 * Servlet implementation class SimpleServlet
 *//*
@WebServlet(description = "A simple serverlet", urlPatterns = { "/patient" })
public class AnnotationServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	*//**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 *//*
	
	SessionFactory factory=null;
	 public void init(){
		 System.out.println("Inside init() method");
		 System.out.println ("Creating factory");
		 try
		 {
			 //factory = new Configuration().configure().buildSessionFactory();
			 Configuration config = new Configuration();
			 config.addAnnotatedClass(Customer.class);
			 factory = config.configure().buildSessionFactory();
			 System.out.println("factory ready");
		 
		 }catch(Exception e1){ 
			 e1.printStackTrace();
			 System.out.println("" + e1);
		 }
	}
	 
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		System.out.println("doPost from annation servlet called!");
		PrintWriter pw = response.getWriter();
		pw.println("this is annotation servlet</br>");
		String userName = request.getParameter("userName");
		String id = request.getParameter("id");
		pw.println("Hello, " + userName + "!");
		pw.println("Your password: " + id);
		String fName = request.getParameter("fName");
		String lName = request.getParameter("lName");
		String address = request.getParameter("address");
		String tel = request.getParameter("tel");
		pw.println("fName: " + fName + "</br>");
		pw.println("lName: " + lName + "</br>");
		pw.println("address: " + address + "</br>");
		pw.println("tel: " + tel);
		//store(fName, lName, address, tel);
		
		Transaction tx = null;
		try
		 {
			 Session session = factory.openSession();
			 tx = session.beginTransaction();
			 Customer customer = new Customer();
			 customer.setFirstName(fName);
			 customer.setLastName(lName);
			 customer.setAddress(address);
			 customer.setTel(tel);
			 session.save(customer);
			 tx.commit();
			 session.flush();
			 session.close();
			 pw.println("<h1> 1 Record added </h1>");
		 }
		 catch(Exception e1)
		 { e1.printStackTrace();
			 System.out.println("" + e1);
			 
			 pw.println("Exception Caught :" + e1);
		 
		 }
	}

	*//**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 *//*
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		System.out.println("doGet from annotation servlet called!");
		PrintWriter pw = response.getWriter();
		pw.println("this is XML serverlet");
		String fName = request.getParameter("fName");
		String lName = request.getParameter("lName");
		String address = request.getParameter("address");
		String tel = request.getParameter("tel");
		pw.println("fName: " + fName);
		pw.println("lName: " + lName);
		pw.println("address: " + address);
		pw.println("tel: " + tel);
		//store(fName, lName, address, tel);
		
		//HibernateUtil.storeCustomer(fName, lName, address, tel);
		//doGet(request, response);
		
		
		
		
	}//end doPost
	
	public void store(String fName, String lName, String address, String tel){
		Session session = HibernateUtil.beginTransaction();
		Customer customer = new Customer();
		
		customer.setFirstName(fName);
		customer.setLastName(lName);
		customer.setAddress(address);
		customer.setTel(tel);
		
		session.saveOrUpdate(customer);
		//session.saveOrUpdate(user);
		System.out.println("user saved");
		HibernateUtil.commitTransaction();
		System.out.println("transaction successful");
		
	}//end store

}
*/